package com.blog.login.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * @author admin
 * @version 1.0 <br/>
 * <p style="font-family:SimSun;font-weight:bold">时间:<br/>2021/12/10 13:21</p>
 */

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        List<String> list=new ArrayList<>();
        list.add("https://blogim.oss-cn-beijing.aliyuncs.com/my_file/15e012de-fafe-4d14-9c6b-abc228080fd0.png");
        list.add("https://blogim.oss-cn-beijing.aliyuncs.com/my_file/4000d6b7-4220-4778-a82e-3e6f263359b0.jpeg");
        list.add("https://blogim.oss-cn-beijing.aliyuncs.com/my_file/774c58bd-7c94-4570-890b-e0dabd8062dc.jpeg");
        list.add("https://blogim.oss-cn-beijing.aliyuncs.com/my_file/ee1438dc-045a-42f8-8242-a8493f6a75bb.jpg");
        list.add("https://blogim.oss-cn-beijing.aliyuncs.com/my_file/f448e52b-fbac-42e8-b1de-1353e9a84790.jpg");
        Random random=new Random();
        int i = random.nextInt(5);
        this.setFieldValByName("userRegisterTime",new Date(),metaObject);
        this.setFieldValByName("userPhoto",list.get(i),metaObject);

    }
    @Override
    public void updateFill(MetaObject metaObject) {
    }
}
